﻿using HyEduOnline.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace HyEduOnline.Models
{
    public static class FrontUserInfo
    {
        public static int GetUserID()
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            if (tempSession["UserID"] == null)
            {
                return -1;
            }
            else
            {
                return Convert.ToInt32(tempSession["UserID"]);
            }

        }

        public static void InitialTeacherInfo(TbStudents stu)
        {
             HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
             tempSession["UserID"] = stu.Id;

        }

        public static void ClearSession()
        {
             HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            tempSession.Clear();
        }


       
        /// <summary>
        /// 取得当前用户类型，0学生，1教师，2管理员，3所有用户
        /// </summary>
        /// <returns></returns>
        public static string GetUserType()
        {
             HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
             if (!string.IsNullOrEmpty(tempSession["UserType"].ToString()))
            {
                string UserType = tempSession["UserType"].ToString();
                return UserType;
            }
            return "";
        }



        
        /// <summary>
        /// 设置当前用户名称
        /// </summary>
        /// <param name="CurrentUserName"></param>
        public static void SetCurrentUserName(string CurrentUserName)
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

            tempSession["CurrentUserName"] = CurrentUserName;


        }



        /// <summary>
        ///  设置当前用户名称
        /// </summary>
        /// <returns></returns>
        public static string GetUserName()
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            if (tempSession["CurrentUserName"] == null)
            {
                return "-1";
            }
            else
            {
                return Convert.ToString(tempSession["CurrentUserName"]);
            }

        }

        /// <summary>
        /// 获取当前管理员的用户名
        /// </summary>
        /// <returns></returns>
        public static string GetSysUserName()
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            if (tempSession["UserName"] == null)
            {
                return "-1";
            }
            else
            {
                //return Convert.ToInt32(tempSession["CurrentUserNo"]);
                return Convert.ToString(tempSession["UserName"]);
            }

        }
        /// <summary>
        /// 获取当前管理员的用户名
        /// </summary>
        /// <returns></returns>
        public static string GetSysUserTureName()
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            if (tempSession["TrueName"] == null)
            {
                return "-1";
            }
            else
            {
                //return Convert.ToInt32(tempSession["CurrentUserNo"]);
                return Convert.ToString(tempSession["TrueName"]);
            }

        }

        //
        /// <summary>
        /// 设置当前用户No
        /// </summary>
        /// <param name="CurrentUserNo"></param>
        public static void SetCurrentUserNo(string CurrentUserNo)
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

            tempSession["CurrentUserNo"] = CurrentUserNo;


        }

   
        public static string GetUserNo()
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            if (tempSession["CurrentUserNo"] == null)
            {
                return "-1";
            }
            else
            {
                //return Convert.ToInt32(tempSession["CurrentUserNo"]);
                return Convert.ToString(tempSession["CurrentUserNo"]);
            }

        }
    


    }
}